Skip to content

Properly build text node for junit output formatter#7917

Merged
samsonasik merged 1 commit intorectorphp:mainfrom
brandonja991:bugfix/junit-output
Feb 25, 2026
Merged

Properly build text node for junit output formatter#7917
samsonasik merged 1 commit intorectorphp:mainfrom
brandonja991:bugfix/junit-output

Conversation

@brandonja991
Copy link
Contributor

Fixes rectorphp/rector#9674

Fixes issue when diff contains ampersands causing XML produced to result in parse error due to unescaped ampersands.

@samsonasik
Copy link
Member

/cc @VitalyArt since you originally create the junit formatter, could you verify it? Thank you.

@VitalyArt
Copy link
Contributor

@samsonasik Yes, this fixes the problem.

Before fix (invalid xml):

<?xml version="1.0" encoding="UTF-8"?>
<testsuites><testsuite name="rector"><testcase file="example.php" name="example.php:1"><error type="TernaryToNullCoalescingRector">--- Original
+++ New
@@ -1,3 +1,3 @@
 &lt;?php

-$foo = isset($bar) ? $bar : ($baz & $qux);
+$foo = $bar ?? ($baz & $qux);
</error></testcase></testsuite></testsuites>

After fix:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites><testsuite name="rector"><testcase file="example.php" name="example.php:1"><error type="TernaryToNullCoalescingRector">--- Original
+++ New
@@ -1,3 +1,3 @@
 &lt;?php

-$foo = isset($bar) ? $bar : ($baz &amp;&amp; $qux);
+$foo = $bar ?? ($baz &amp;&amp; $qux);
</error></testcase></testsuite></testsuites>

@samsonasik
Copy link
Member

Thank you @VitalyArt for verify, and thank you @brandonja991 for the fix.

@TomasVotruba let's merge this ;)

@samsonasik samsonasik merged commit 44a8dfc into rectorphp:main Feb 25, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JUnit File Parse Error

3 participants